<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('单据查询列表')" />
	<th:block th:include="include :: list-css" />
    <style>
       /* .layui-border-box{height: 400px !important;}
		.layui-table-body{height: 290px !important;} */
        .layui-tab-title{border-color: #ccc !important;}
        .layui-this{color: rgb(0, 135, 250) !important;background: none !important;}
        .layui-tab-brief > .layui-tab-title .layui-this:after, .layui-tab-brief > .layui-tab-more li.layui-this:after{border-color:  rgb(0, 135, 250) !important;}
        .mid-content {overflow: auto;}

        /* .layui-table-body{overflow-y: auto;overflow-x: hidden;} */
        /* .layui-table-body{} */
    </style>
</head>
<body class="no-skin">
<script type="text/html" id="toolbar">
	<div class="layui-btn-container">
		<!-- <div class="layui-btn layui-btn-normal layui-table-tools" lay-event="addbtn">
			<i class="dhicon dh-lujing1089"></i> 新增
		</div> -->
        <div class="layui-btn layui-btn-normal layui-table-tools" lay-event="deleteBatch" th:if="${extraButton.deleteBatch}">
			<i class="dhicon dh-remove"></i> 删除
		</div>
        <div class="layui-btn layui-btn-normal layui-table-tools ishide" id="shbtn" lay-event="shbtn" th:if="${extraButton.shbtn}">
			<i class="dhicon dh-zu4491"></i> 审核
		</div>
        <div class="layui-btn layui-btn-normal layui-table-tools ishide" id="tsshbtn" lay-event="tsshbtn" th:if="${extraButton.tsshbtn}">
			<i class="dhicon dh-zu4491"></i> 特殊审核
		</div>
        <div class="layui-btn layui-btn-normal layui-table-tools ishide" id="sxdd" lay-event="sxdd" th:if="${extraButton.sxdd}">
			<i class="dhicon layui-icon-cols"></i> 刷新订单信息
		</div>
        <div class="layui-btn layui-btn-normal layui-table-tools isshow" id="htbtn" lay-event="htbtn" th:if="${extraButton.htbtn}">
			<i class="dhicon dh-zu4491"></i> 回退
		</div>
		<div class="layui-btn layui-btn-normal layui-table-tools isshow" id="xsfkbtn" lay-event="xsfkbtn" th:if="${extraButton.xsfkbtn}">
			<i class="dhicon layui-icon-cols"></i> 线上付款
		</div>
        <div class="layui-btn layui-btn-normal layui-table-tools ishide" lay-event="viewBeforeCreatebtn" th:if="${extraButton.viewBeforeCreatebtn}">
			<i class="dhicon dh-add-cart"></i> 查看优惠活动
		</div>
        <div class="layui-btn layui-btn-normal layui-table-tools ishide" lay-event="scbtn" th:if="${extraButton.scbtn}">
			<i class="dhicon dh-add-cart"></i> 创建订单
		</div>
        <div class="layui-btn layui-btn-normal layui-table-tools ishide" lay-event="qxbtn" th:if="${extraButton.qxbtn}">
			<i class="dhicon dh-remove"></i> 取消订单
		</div>
        <div class="layui-btn layui-btn-normal layui-table-tools" lay-event="exportbtn" th:if="${extraButton.exportbtn}">
			<i class="dhicon dh-zu4250_2_2"></i> 导出
		</div>
    </div>
	
</script>

<!-- 表格操作区 -->
<script type="text/html" id="barDh">
	<a class="layui-btn layui-btn-danger layui-btn-xs isshow" onclick="wledit('{{d.guid}}','{{d.bid}}','{{d.warehouse}}','{{d.aliPlace}}','{{d.aliLogisticsBillNo}}','{{d.nid}}')" th:if="${extraButton.wledit}">物流修改</a>
	<a class="layui-btn layui-btn-disabled layui-btn-xs isshow"  th:if="!${extraButton.wledit}">物流修改</a>

    <a class="layui-btn layui-btn-danger layui-btn-xs isshow" onclick="wlbtn('{{d.bid}}')" th:if="${extraButton.wlgjbtn}">物流轨迹</a>
    <a class="layui-btn layui-btn-disabled layui-btn-xs isshow"  th:if="!${extraButton.wlgjbtn}">物流轨迹</a>
</script>


<script th:inline="javascript">
    /*<![CDATA[*/
    var gridColumns = [[${gridColumns}]],
        business = [[${purchase}]],
        buttonState = [[${buttonState}]],
        businessName = gridColumns.moduleAlias,
		extraButton = [[${extraButton}]],
        passwordAuthentication = [[${passwordAuthentication}]],
		ali1688AppKey = [[${ali1688AppKey}]],
		ali1688EcpApiUrl = [[${ali1688EcpApiUrl}]],
		session = [[${session}]],
        moduleTable = [[${moduleTable}]];

    /*]]>*/
    var prefix = "/purchase/"+business;
	var tableUrl = prefix + "/list?state=待审核",
	openRowUrl = "/purchase/"+(business.split('/')[1]?business.split('/')[0]:business)+"/edit?nid=";
	exportUrl = prefix + "/export";
	delUrl = prefix+"/delete";
</script>
<th:block th:include="listinclude :: purchase" />
<th:block th:include="include :: footer" />
<th:block th:include="include :: tableBtn" />
<th:block th:include="listinclude :: list-templeat" />
<th:block th:include="include :: searchJS" />
<th:block th:include="include :: listJS" />

<script>
    $('.istype').show()
	$(document).ready(function(){
		setTimeout(function(){
			$('.layui-table-fixed-r').hide()
		},800)
    })
	function wlbtn(bid){
		$.get(ali1688EcpApiUrl+'/api/1688/get1688OrderTraceInfo',{'orderNo':bid,'userId':session.userId},function(res){
			if(res.code==0 && res.data){
				layer.open({
                  type: 1,
			      title:'物流轨迹',
                  area: ['700px', '500px'], //宽高
                  content: htmldiv(JSON.stringify(res.data.reverse()))
                });
			}else{
                layer.msg('暂无物流轨迹')
			}
		});
	}

	function wledit(guid,bid,warehouse,aliPlace,aliLogisticsBillNo,nid){
		layer.open({
            type: 1,
		    title:'物流轨迹',
            area: ['500px', '300px'], //宽高
            content:`<div class="layui-row" style="padding:20px 0;">
			        <div class="layui-inline layui-col-sm12">
                        <label class="layui-form-label">单据编号：</label>
                        <div class="layui-input-block">
                            <input id="bid" type="text" name="bid" autocomplete="off" value="${bid}" disabled class="layui-input">
                        </div>
                    </div>
					<div class="layui-inline layui-col-sm12">
                        <label class="layui-form-label">物流渠道：</label>
                        <div class="layui-input-block">
                            <input id="aliPlace" type="text" name="aliPlace" autocomplete="off" value="${aliPlace}" class="layui-input">
                        </div>
                    </div>
					<div class="layui-inline layui-col-sm12">
                        <label class="layui-form-label">物流运单号：</label>
                        <div class="layui-input-block">
                            <input id="aliLogisticsBillNo1" type="text" name="aliLogisticsBillNo" autocomplete="off" value="${aliLogisticsBillNo}" class="layui-input">
                        </div>
                    </div>
				</div>`,
				btn: ['确定', '取消'],
    			yes: function(index, layero){
					showloadings(true);
					var data={guid,bid,warehouse,'aliPlace':$('#aliPlace').val(),'aliLogisticsBillNo':$('#aliLogisticsBillNo1').val(),nid}
    			    $.post("/purchase/purchaseorder/saveLogistics",{'infoItems':JSON.stringify(data)},function(res){
                        layer.msg(res.msg)
                        if(res.code==0){
                            setTimeout(function(){
								table.reload('dhtable');
								layer.close(index); //如果设定了yes回调，需进行手工关闭
                            }, 800);
                        }
						showloadings(false);
                    })
    			}
    	});
	}

	function htmldiv(arr){
       var data=JSON.parse(arr)
	   var str='<ul class="layui-timeline" style="padding:10px 20px;">'
        for(var i=0;i<data.length;i++){
			str+=`<li class="layui-timeline-item">
                  <i class="layui-icon layui-timeline-axis"></i>
                  <div class="layui-timeline-content layui-text">
                    <h3 class="layui-timeline-title">${data[i].acceptTime}</h3>
                    <p>${data[i].remark}</p>
                  </div>
                </li>`
		}
		str+='</ul>'
		return str
	}

	
</script>

</body>
</html>